﻿#region 命名空间

using System;

#endregion

namespace Sharp.Domain.CMSBoundedContext.AritcleModule.GatherEngine
{
    /// <summary>
    /// 采集规则
    /// </summary>
    public enum GatherRuleType
    {
        Regular,
        XPath,
        DomQuery
    }

    public class GatherRule
    {
        /// <summary>
        /// 分析采集规则属于哪种类型
        /// </summary>
        /// <param name="rule"></param>
        /// <returns></returns>
        public static GatherRuleType Analysis(string rule)
        {
            if (rule.StartsWith("D:", StringComparison.CurrentCultureIgnoreCase))
            {
                return GatherRuleType.DomQuery;
            }
            if (rule.StartsWith("X:", StringComparison.CurrentCultureIgnoreCase))
            {
                return GatherRuleType.XPath;
            }
            return GatherRuleType.Regular;
        }
    }
}